class Solution(object):
    def canReach(self, s, minJump, maxJump):
        if s[-1] == '1':
            return False
        n = len(s)
        diff = [0] * n
        diff[0] = 1
        diff[1] = -1
        now = 0
        for i in range(n):
            now += diff[i]
            if now > 0:
                if s[i] == '0':
                    if i + minJump < n:
                        diff[i + minJump] += 1
                    if i + maxJump + 1 < n:
                        diff[i + maxJump + 1] -= 1
            else:
                if i == n - 1:
                    return False
        return True



